StudentsPerformance <- read.csv("C:/Users/ASUS/Downloads/StudentsPerformance.csv")
1. Trực quan hóa bằng đồ thị Boxplot.
Để kiểm tra ảnh hưởng của biến phân loại
test.preparation.course lên các biến phụ thuộc
math.score, reading.score, writing.score, ta
sẽ sử dụng biểu đồ Boxplot. Biểu đồ này sẽ giúp ta so sánh sự phân bố
điểm của từng bài thi giữa các nhóm có và không có sự chuẩn bị.
Ta sử dụng thư viện ggplot2 và plotly để vẽ biểu đồ
Boxplot.
library(ggplot2)
library(plotly)
library(shiny)
Khởi tạo lần lượt 3 biểu đồ
graph1 <- ggplot(
StudentsPerformance, aes(x=test.preparation.course, y=math.score, fill=test.preparation.course))+
geom_boxplot()+
labs(title= "Ảnh hưởng của test.prepartion.course lên math.score",x="test.preparation.course",y="math.score")+
scale_fill_brewer(palette = "Set2")+ #đổi màu biểu đồ
theme(legend.position="none", plot.title = element_text(hjust = 0.5, size = 13)
)
graph2 <- ggplot(
StudentsPerformance, aes(x=test.preparation.course, y=reading.score, fill=test.preparation.course))+
geom_boxplot()+
labs(title="Ảnh hưởng của test.prepartion.course lên reading.score",x="test.preparation.course",y="reading.score")+
scale_fill_brewer(palette="Pastel1")+
theme(legend.position="none", plot.title = element_text(hjust = 0.5, size = 13)
)
graph3 <- ggplot(
StudentsPerformance, aes(x=test.preparation.course, y=writing.score, fill=test.preparation.course)) +
geom_boxplot()+
labs(title= "Ảnh hưởng của test.prepartion.course lên writing.score", x="test.preparation.course",y="writing.score") +
theme(legend.position="none", plot.title = element_text(hjust = 0.5, size = 13)
)
2.Nhận xét:
Biểu đồ Boxplot cho điểm toán (math.score):
Biểu đồ Boxplot cho điểm đọc (reading.score):
Biểu đồ Boxplot cho điểm viết (writing.score):
Kết luận: